#include "include/volumeControl.h"

void initialIO(){


    setDirSDO=Output_Pin;
    setDirSCK=Output_Pin;
    setDirCS =Output_Pin;
    setDirVR =Input_Pin;

    // Unlock Registers
    __builtin_write_OSCCONL(OSCCON & 0xBF);
    //RB15 output  RP29  SDO
    RPOR14bits.RP29R=7;
    //RB14 output  RP14  SCK
    RPOR7bits.RP14R =8;
    // Lock Registers
    __builtin_write_OSCCONL(OSCCON | 0x40);
    
    //Setup PORTB IO and anlogo input
    AD1PCFG=0xfe;

}

void initialADC(){



}

void initialSPI(){

OpenSPI1(ENABLE_SCK_PIN&
         ENABLE_SDO_PIN&
         MASTER_ENABLE_ON&
         SPI_MODE16_ON&
         SPI_SMP_ON&
         SPI_CKE_ON&
         SLAVE_ENABLE_OFF,
         FRAME_ENABLE_OFF&
         FRAME_SYNC_OUTPUT,
         SPI_IDLE_CON&
         SPI_ENABLE
        );
}

void volumeValue(int gain){
    
    WriteSPI1(gain);

}